
#if !defined(AFX_ClientVersionDlg_H__A7EB85C3_1EEA_4FEC_8450_C090219B8619__INCLUDED_)
#define AFX_ClientVersionDlg_H__A7EB85C3_1EEA_4FEC_8450_C090219B8619__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include "../client/Util.h"
#include "../client/ClientVersionManager.h"
#include "WinUtil.h"

#include "PropPage.h"

class ClientVersionDlg : public CDialogImpl<ClientVersionDlg>
{
	CEdit ctrlClientName, ctrlLastVersion, ctrlCurrentVersion, 
		ctrlComment, ctrlAddress, ctrlClientAddress, ctrlUpdateTime;


	CButton ctrlAlert, ctrlUpdated;

public:
	
	string clientName;
	string lastVersion;
	string currentVersion;
	string comment;
	string address;
	string clientAddress;
	string updateTime;
	bool alert;
	bool updated;
	int currentVersionId;

	ClientVersion currentVersionProfile;

	enum { IDD = IDD_CLIENT_VERSION };

	BEGIN_MSG_MAP(ClientVersionDlg)
		MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog)
		MESSAGE_HANDLER(WM_SETFOCUS, onFocus)
		COMMAND_ID_HANDLER(IDOK, OnCloseCmd)
		COMMAND_ID_HANDLER(IDCANCEL, OnCloseCmd)
		COMMAND_ID_HANDLER(IDC_SITE, OnLink)
		COMMAND_ID_HANDLER(IDC_XML, OnLink)
	END_MSG_MAP()

	ClientVersionDlg() : alert(0), updated(0){ };

	LRESULT onFocus(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) {
		ctrlClientName.SetFocus();
		return FALSE;
	}

	LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/);
	LRESULT OnLink(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/);
	LRESULT OnCloseCmd(WORD /*wNotifyCode*/, WORD wID, HWND /*hWndCtl*/, BOOL& /*bHandled*/) {
		if(wID == IDOK) {
			updateVars();
			if(clientName.empty()||address.empty()){
				MessageBox(CTSTRING(ADDRESS_OR_NAME_EMPTY), CTSTRING(ERRORS), MB_ICONSTOP);
				return 0;
			}
			
			
		}
		EndDialog(wID);
		return 0;
	}
private:
	enum { BUF_LEN = 1024 };
	void updateVars();
	void updateControls();
	void getProfile();
};

#endif